package com.tim.app.ui.activity.selected;

import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.widget.ImageButton;

import com.application.library.runtime.event.EventListener;
import com.application.library.runtime.event.EventManager;
import com.lzy.okhttputils.OkHttpUtils;
import com.tim.app.R;
import com.tim.app.constant.EventTag;
import com.tim.app.ui.activity.BaseActivity;
import com.tim.app.ui.fragment.selceted.AtFragment;

/**
 * @页面
 */
public class AtSomeOneActivity extends BaseActivity {

    private static final String TAG = "AtSomeOneActivity";

    private ImageButton ibBack;


    @Override
    protected void onBeforeSetContentLayout() {
        super.onBeforeSetContentLayout();
    }

    @Override
    protected int getLayoutId() {

        return R.layout.activity_at;
    }

    @Override
    public void initView() {
        ibBack = (ImageButton) findViewById(R.id.ibBack);
        ibBack.setOnClickListener(this);
        showAtList();
        EventManager.ins().registListener(EventTag.ON_AT,eventListener);
    }

    private void showAtList(){
        FragmentManager fm = getSupportFragmentManager();
        FragmentTransaction transaction = fm.beginTransaction();
        transaction.replace(R.id.flContainer, new AtFragment());
        transaction.commitAllowingStateLoss();
    }

    @Override
    public void initData() {

    }
    EventListener eventListener = new EventListener() {
        @Override
        public void handleMessage(int what, int arg1, int arg2, Object dataobj) {
            switch (what){
                case EventTag.ON_AT:
                   finish();
                    break;
            }

        }
    };


    @Override
    public void onClick(View v) {

        switch (v.getId()) {
            case R.id.ibBack:
                finish();
                break;
        }

    }

    @Override
    protected void onResume() {
        super.onResume();
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        OkHttpUtils.getInstance().cancelTag(TAG);
        EventManager.ins().removeListener(EventTag.ON_AT,eventListener);
    }

}
